package com.sskj.tibi.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.tibi.bean.CommissionConfigBean;
import com.sskj.tibi.bean.FinanceBean;
import com.sskj.tibi.http.HttpConfig;
import com.sskj.tibi.ui.activity.CommissionWithdrawActivity;


public class CommissionWithdrawActivityPresenter extends BasePresenter<CommissionWithdrawActivity> {
    public void getData() {
        httpService.apiUserCommissionConfig()
                .execute(new JsonCallBack<HttpData<CommissionConfigBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<CommissionConfigBean>> response) {
                        HttpData<CommissionConfigBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateUI(httpData.getData());
                        }
                    }
                });
    }

    public void withdraw(String money, String payment_password) {
        httpService.withdrawCommission(money, payment_password)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.withdrawSuccess();
                        }
                    }
                });
    }
    /**
     * 资产信息
     *
     * @return
     */
    public void apiUserAssetinfo() {
        httpService.apiUserAssetinfo().execute(new JsonCallBack<HttpData<FinanceBean>>() {
            @Override
            public void onSuccess(Response<HttpData<FinanceBean>> response) {
                HttpData<FinanceBean> httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {
                    mView.updateMoney(httpData.getData());
                }
            }

        });
    }


}
